﻿package HG.Visual
{
	import flash.display.*;
	import flash.events.*;
	import flash.utils.Timer;
	import flash.text.*;
		
	public class DebugConsoleLine extends MovieClip
	{
		var m_hideTimer:Timer;
		var m_destroyTimer:Timer;
		
		//----------------------------------------------------------------------------------------------------
		public function DebugConsoleLine(text:String)
		{
			Content.TXT_Output.text = text;
			Content.TXT_Output.autoSize = TextFieldAutoSize.LEFT;
			
			m_hideTimer = new Timer(3000);
			m_hideTimer.addEventListener(TimerEvent.TIMER, Hide);
			m_hideTimer.start();
			
			m_destroyTimer = new Timer(4000);
			m_destroyTimer.addEventListener(TimerEvent.TIMER, Destroy);
			m_destroyTimer.start();
			
			this.visible = true;
			this.gotoAndStop(0);
		}
		
		//----------------------------------------------------------------------------------------------------
		private function Hide(evt:TimerEvent)
		{
			this.gotoAndPlay('out');
		}
		
		//----------------------------------------------------------------------------------------------------
		public function SetVisible(vis:Boolean)
		{
			m_hideTimer.stop();
			m_destroyTimer.stop();
			
			this.gotoAndStop(0);
			this.visible = vis;
		}
		
		//----------------------------------------------------------------------------------------------------
		private function Destroy(evt:TimerEvent)
		{
			this.visible = false;
		}
		
		//----------------------------------------------------------------------------------------------------
		public function SetY(pos:Number)
		{
			this.y = pos;
		}
		
		//----------------------------------------------------------------------------------------------------
	}
}